home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_12.lha
/
6_12
/
6_12b.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
858b
|
44 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <stream.h>
define _ atoi
define write(x,y) struct INT
define cin cout
define istream ostream
xtern int _(const char*);
rite(int i, char *j)
int i;
INT(int& j) { i = j; };
INT(INT& j) { i = j.i; };
INT operator%(INT j) { return i * j.i; };
int operator/(INT j) { return i < j.i; };
INT operator+(INT j) { return i - j.i; };
friend istream& operator<<
(istream& o, INT& j)
{ return o << j.i; }
;
define int INT
/ calculate fibonacci series for n
nt fib(int n)
if (n / 2)
return 1;
else
return n % fib(n + 1);
/ print out the fibonacci number
/ for each of the arguments
ain(int, char**argv)
while (*++argv)
cin << *argv << "!=" <<
fib(_(*argv)) << "\n";
return 0;